import { Controller, Get, Query } from "@nestjs/common";
import { genRes, ResObjPropNameConst } from "st-common-req";
import { RoleService } from "./role.service";
import { RoleResultMessage } from "./consts/role-result-message";

/**
 * 角色控制器
 */
@Controller('role')
export class RoleController {

  constructor(
    private readonly roleService: RoleService,
  ) {
  }

  @Get()
  async get(@Query() filters: Record<string, any>) {
    // 获取所有角色信息列表
    const roleVos = await this.roleService.find(filters);
    // 获取失败
    if (!roleVos) return genRes({
      [ResObjPropNameConst.STATUS]: false,
      [ResObjPropNameConst.MESSAGE]: RoleResultMessage.DEL_SUCCESS,
    })
    return genRes({
      [ResObjPropNameConst.MESSAGE]: RoleResultMessage.GET_SUCCESS,
      [ResObjPropNameConst.DATA]: roleVos,
    })
  }

}
